home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 279 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.7 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: thp@cs.ucr.edu (Tom Payne)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Throwing an exception from within a signal handler
  5. Date: 4 Feb 1996 18:28:44 GMT
  6. Organization: University of California, Riverside Department of Computer Science
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <4f2th6$4qh@galaxy.ucr.edu>
  9. References: <4dgj4m$9la@engnews1.Eng.Sun.COM> <DLCosx.Hn1@falcon.daytonoh.attgis.com>
  10. NNTP-Posting-Host: taumet.eng.sun.com
  11. Content-Type: text
  12. X-Nntp-Posting-Host: corvette.ucr.edu
  13. X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
  14. Content-Length: 2075
  15. Originator: clamage@taumet
  16.  
  17. J. Kanze (kanze@gabi.gabi-soft.fr) wrote:
  18. : In article <4ebptg$frt@galaxy.ucr.edu> thp@cs.ucr.edu (Tom Payne)
  19. : writes:
  20. : > : From ISO 9899, section 7.7.1.1: ``If the signal occurs other than as the
  21. : > : result of calling the abort or raise function, the behavior is undefined
  22. : > : if the signal handler calls any function in the standard library other
  23. : > : than the signal function itself (with a first argument of the signal
  24. : > : number corresponding to the signal tha caused the invocation of the
  25. : > : handler) or refers to any object with static storage duration other than
  26. : > : by assigning a value to a static storage duration variable of type
  27. : > : volatile sig_atomic_t.''
  28. : > [...]
  29. : > 
  30. : > In other words, the only asynchronous activity allowed to programs
  31. : > with defined behavior is polling volatile atomic variables that are
  32. : > set by signal handlers.  Thus far, no one has given me a reason for
  33. : > prohibiting signal handlers from reading volatile atomic variables,
  34. : > which is a common practice in interrupt handlers (even those written
  35. : > in C/C++).
  36. : Correct.  In practice, I cannot conceive of an implementation where
  37. : writing something would be atomic, but reading it wouldn't.  On the
  38. : other hand, read/modify/write will frequently not be atomic.  And why
  39. : else might you want to read an object in a signal handler, if not to
  40. : modify it?
  41.  
  42. Atomicity of such updates to atomic variables is not always a problem.
  43. For instance, in most cases a signal handler can increment an atomic
  44. counter (e.g. a timer) without difficulties, even though the
  45. read/modify/write sequence is not atomic.  In the case of nonatomic
  46. variables, atomicity must be enforced by blocking certain signals.
  47. Such blockage could be portably implemented via atomic blockage flags,
  48. which, in turn, are volatile atomic variables that must be read by
  49. signal handers.
  50.  
  51. Tom Payne  (thp@cs.ucr.edu)
  52.  
  53. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  54.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy is
  55.   summarized in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  56. ]
  57.